package com.assistant.markdown;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * UnOrderedList
 *
 * @author yingjianhua
 */
@Getter
public class UnorderedList implements Content {

    private final List<Content> contents = new ArrayList<>();

    public UnorderedList append(Content content) {
        this.contents.add(content);
        return this;
    }

    public int size() {
        return contents.size();
    }

    public Content get(int index) {
        return contents.get(index);
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        int index = 1;
        for (Content content : contents) {
            if (index != 1) {
                stringBuilder.append("\n");
            }
            stringBuilder.append("- ").append(content.toString());
            index++;
        }
        return stringBuilder.toString();
    }
}
